﻿layui.use(['table', 'dropdown', 'layer', 'form'], function () {
    var table = layui.table;
    var dropdown = layui.dropdown;
    var layer = layui.layer;
    var form = layui.form;
    var laypage = layui.laypage;
    //反填显示复检信息
    //反填

    $(function () {
        fantian1();//不合格复检信息
        fantian2();//合格复检信息
        
    })
    //不合格反填复检信息
    function fantian1() {
        // 发送AJAX请求获取数据
        console.log(localStorage.getItem("reinspectionId"))
        $.ajax({
            type: "get",
            url: "/Quality/GetByidRein",
            data: {
                ReinspectionId: localStorage.getItem("reinspectionId"),
                token: localStorage.getItem("token")
            },
            success: function (res) {
                var ter = JSON.parse(res)
                console.log(ter.data)

                $(ter.data).each(function () {
                    $('#QualityNumber22').val(this.qualityNumber);
                    $('#QualityName22').val(this.qualityName);
                    $('#QualityTime22').val(this.qualityTime.substring(0, 10));
                    $('#Qualityer22').val(this.qualityer);
                    $('#Supplier22').val(this.supplier);
                    $('#MaterialNumber22').val(this.materialNumber);
                    $('#MaterialName22').val(this.materialName);
                    $('#Unit22').val(this.unit);
                    $('#SpecificationsModel22').val(this.specificationsModel);
                    $('#batchNumber22').val(this.batchNumber);
                    $('#Size22').val(this.size);
                    $('#ReinspectionNumber22').val(this.unqualifiedQuantity);
                    $('#BuHege2').val(this.unqualifiedQuantity);
                    $('#notes2').val(this.remark);
                    $('#hege2').val(this.acceptanceQuantity);

                    $('#ReInCode22').val(this.reinspectionCode);
                    $('#HeGeSarte22').val(this.heGeSarte);
                    $('#ReinspectionNote22').val(this.reinspectionNote);
                    $('#ReinspectionName22').val(this.reinspectionName);
                    $('#ReinspectionTime22').val(this.reinspectionTime.substring(0, 10));
                    $('#ReinspectionNumber22').val(this.reinspectionNumber);
                    $('#ReName22').val(this.reName);
                    localStorage.setItem("ids", this.rawMaterialQualityId)
                })

            },

        });


    }
    //合格反填复检信息
    function fantian2() {
        // 发送AJAX请求获取数据
        console.log(localStorage.getItem("reinspectionId"))
        $.ajax({
            type: "get",
            url: "/Quality/GetByidRein",
            data: {
                ReinspectionId: localStorage.getItem("reinspectionId"),
                token: localStorage.getItem("token")
            },
            success: function (res) {
                var ter = JSON.parse(res)
                console.log(ter.data)

                $(ter.data).each(function () {
                    $('#QualityNumber2').val(this.qualityNumber);
                    $('#QualityName2').val(this.qualityName);
                    $('#QualityTime2').val(this.qualityTime.substring(0, 10));
                    $('#Qualityer2').val(this.qualityer);
                    $('#Supplier2').val(this.supplier);
                    $('#MaterialNumber2').val(this.materialNumber);
                    $('#MaterialName2').val(this.materialName);
                    $('#Unit2').val(this.unit);
                    $('#SpecificationsModel2').val(this.specificationsModel);
                    $('#batchNumber2').val(this.batchNumber);
                    $('#Size2').val(this.size);
                    $('#ReinspectionNumber2').val(this.unqualifiedQuantity);
                    $('#BuHege').val(this.unqualifiedQuantity);
                    $('#notes').val(this.remark);
                    $('#hege').val(this.acceptanceQuantity);

                    $('#ReInCode2').val(this.reinspectionCode);
                    $('#HeGeSarte2').val(this.heGeSarte);
                    $('#ReinspectionNote2').val(this.reinspectionNote);
                    $('#ReinspectionName2').val(this.reinspectionName);
                    $('#ReinspectionTime2').val(this.reinspectionTime.substring(0, 10));
                    $('#ReinspectionNumber2').val(this.reinspectionNumber);
                    $('#ReName2').val(this.reName);
                   
                })

            },

        });


    }
    var obj1 ={
        ReinspectionId: "",
        RawMaterialQualityId:""
    }
    //销毁
    window.ShowXiaohui = function ShowXiaohui() {
        obj1.ReinspectionId = localStorage.getItem("reinspectionId")
        obj1.RawMaterialQualityId = localStorage.getItem("ids")
        $.ajax({
            type: "post",
            url: "../Quality/XiaohuiRein",  // 替换为实际的后台删除数据接口地址
            data: { obj1: obj1, token: localStorage.getItem("token") },
            success: function (res) {
                console.log(res)
                var res = JSON.parse(res)
                if (res.code == 1) {
                    layer.alert("销毁成功");
                    location.href = '/Quality/ReInfIndexShow'

                } else {
                    layer.alert("销毁失败");


                }

            },
            error: function () {
                layer.msg('删除失败，请稍后重试', {
                    time: 2000,
                    icon: 2

                });

            }
        });
    }

})